Fix basic usage pencil initialization#140
Merged
romerojosh merged 1 commit intoJun 16, 2026
Merged
Conversation
Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
romerojosh
approved these changes
Jun 16, 2026
romerojosh
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the contribution and good catch @fallintoplace! Changes LGTM!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes the CUDA
initialize_pencilexample kernel used by the basic usage examples.The kernel computes a flattened pencil element index as
l, but wrote initialized values throughdata[i]. That means threads with the same first-dimension coordinate race on the same buffer slots, while most of the pencil allocation is left untouched.This PR updates the device initialization path to store through
data[l], matching the host-side flattened loop already shown in the example. It also tightens the guard tol >= pinfo.sizeso the extra threads from the rounded-up launch do not write past the valid pencil range. The documentation snippet is updated to match the source examples.Validation
git diff --checkdata[i]store andl > pinfo.sizeguard are goneI could not build or run the CUDA/MPI example locally because this machine does not have
nvccormpicxxinstalled.